<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h2>文件能上传</h2>
<form id="f1" enctype="multipart/form-data">
  文件：<input type="file" name="files" multiple/>
  <input type="button" value="上传"/>
</form>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
    $(function(){
        $(':button').on('click', function(){
            //创建FormData
            let formData = new FormData($('#f1')[0])
            //使用ajax上传
            $.ajax({
                url: 'upload',
                type: 'post',
                data: formData,
                processData: false, //告诉jquery不要处理发送的数据
                contentType: false, //告诉jquery不要设置content-type请求类型
                success: function(result) {
                    if(result.code === 200) {
                        alert("上传成功");
                    } else {
                        alert(result.message);
                    }
                }
            })
        })
    })
</script>
</body>
</html>